<?php

if (isset($PHPUNIT)) {
	define("SYRIUS_PATH", "");
} else if (isset($SYRIUS_PATH)){
    define("SYRIUS_PATH", $SYRIUS_PATH);
} else {
	define("SYRIUS_PATH", $_SERVER["DOCUMENT_ROOT"] . "/syrius");
}


/**
 * File Syrius_Require
 * An implementation of autoload with a Syrius_Require class
 * @author Domenico Biancardi
 * @version 1.0
 * @package Syrius
 */


/**
 * Load a class on require
 *
 * @global Syrius_Require $loader
 * @param string $className
 */
function __autoloadSecure($className = "") {

	$list = explode("\\", $className);
	if ($list[0] != "Syrius") {
		// è una classe esterna quindi se non esiste do un errore
		throw new Exception("Class " . $className . " not exists");
	} else {
		$file = explode("_", $list[2]);
		$path = SYRIUS_PATH . "/Syrius/" . $list[1] . "/" . $file[0] . ".php";
		require_once $path;
	}
}

/*
if(!function_exists('__autoload')){
    function __autoload($className){
        try{
            __autoloadSecure($className);
        }catch(Exception $e){
            throw new Exception("fxxxxx");
        }
    }
}*/

spl_autoload_register('__autoloadSecure');

?>